<!DOCTYPE HTML>
<html class="error-page no-js" lang="zh_CN">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">

<title>代码生成器1.0</title> #required_css
</head>

<body>
	<div class="center-wrapper">
		<div class="center-content text-center">
			<div class="row no-m">
				<div class="col-xs-10 col-xs-offset-2 col-sm-10 col-sm-offset-6 col-md-8 col-md-offset-2">
					<form method="post" class="form-horizontal">
						<input type="hidden" name="tables" value="$!tables"/>
						<section class="panel bg-white no-b fadeIn animated shadow">
							<div class="panel-heading">
								<h2>代码生成</h2>
								<h4>4/4</h4>
							</div>
							<div class="panel-body text-left pt20" style="height:300px; overflow: auto;">
								<div id="divProgress" class="row">
									<div class="col-md-3"></div>
									<div class="col-md-6">
										<div id="progress-msg" class="bold mt25 mb5">正在连接数据库并生成....</div>
										<div class="progress progress-sm progress-striped active">
											<div class="progress-bar done" role="progressbar" aria-valuenow="1"
											aria-valuemin="0" aria-valuemax="100" style="width: 1%"></div>
										</div>
									</div>
								</div>
								<div id="divSuccess" class="row hide mt20 pt20">
									<div class="col-md-12 text-center text-success">
										<h3><i class="fa fa-check"></i> 生成成功，已保存在：$!savePath。</h3>
									</div>
								</div>
							</div>
							<div class="panel-footer">
								<a href="javascript:openFolder();" class="btn btn-primary"><i class="fa fa-folder-open"></i> 打开目录</a>
								<a href="$!basePath/open/dev/code/download" class="btn btn-primary"><i class="fa fa-file-zip-o"></i> 打包下载</a>
								<a href="javascript:window.location.reload();" class="btn btn-primary"><i class="fa fa-refresh"></i> 重新生成</a>
								<a href="$!basePath/open/dev/code" class="btn btn-primary"><i class="fa fa-home"></i> 返回首页</a>
							</div>
						</section>
					</form>
				</div>
			</div>
		</div>
	</div>
	#required_js
	<script type="text/javascript">
		$(function(){
			refreshStatus();
		})
		function refreshStatus(){
			$.post("$!basePath/open/dev/code/status",{},function(data){
				var val = data.process;
				var progress = $(".progress-bar");
				progress.attr("aria-valuenow", val);
				progress.css("width", val+"%");
				$("#progress-msg").text(data.msg);
				if(val >= 100){
					$("#divProgress").addClass("hide");
					$("#divSuccess").removeClass("hide");
				}else{
					setTimeout(refreshStatus, 200);
				}
			});
		}
		function openFolder(){
			ns.post("$!basePath/open/dev/code/open/folder",{path:"$!savePath"}, function(success, data){
				if(!success){
					alert(data.message);
				}
			});
		}
	</script>
</body>
</html>